//softmax.c （熊璟怡）
#include "matrix_operations/matrix_operations.h"
#include "data_flattening/Data_flattening.h"
#include <stdio.h>
#include <math.h>

// 假设矩阵是一维数组表示，且已知矩阵行数和列数
void softmax(int rows, int cols, double input[rows][cols], double output[rows][cols]) {
    for (int i = 0; i < rows; i++) {
        double sum = 0.0;
        for (int j = 0; j < cols; j++) {
            output[i][j] = exp(input[i][j]);
            sum += output[i][j];
        }
        for (int j = 0; j < cols; j++) {
            output[i][j] /= sum;
        }
    }
}

